/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jobs.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Paul Tamayo
 */
@Entity
@Table(name = "behavioral_skill")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BehavioralSkill.findAll", query = "SELECT b FROM BehavioralSkill b"),
    @NamedQuery(name = "BehavioralSkill.findById", query = "SELECT b FROM BehavioralSkill b WHERE b.id = :id"),
    @NamedQuery(name = "BehavioralSkill.findByName", query = "SELECT b FROM BehavioralSkill b WHERE b.name = :name"),
    @NamedQuery(name = "BehavioralSkill.findByDescription", query = "SELECT b FROM BehavioralSkill b WHERE b.description = :description")})
public class BehavioralSkill implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1024)
    @Column(name = "name")
    private String name;
    @Size(max = 200)
    @Column(name = "description")
    private String description;
    @JoinTable(name = "jobs_behavioral_skill", joinColumns = {
        @JoinColumn(name = "behavioral_skill_id", referencedColumnName = "id")}, inverseJoinColumns = {
        @JoinColumn(name = "jobs_id", referencedColumnName = "id")})
    @ManyToMany
    private Collection<Jobs> jobsCollection;
    @JoinColumn(name = "relevance_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Relevance relevanceId;
    @JoinColumn(name = "observable_behavior_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private ObservableBehavior observableBehaviorId;

    public BehavioralSkill() {
    }

    public BehavioralSkill(Integer id) {
        this.id = id;
    }

    public BehavioralSkill(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public Collection<Jobs> getJobsCollection() {
        return jobsCollection;
    }

    public void setJobsCollection(Collection<Jobs> jobsCollection) {
        this.jobsCollection = jobsCollection;
    }

    public Relevance getRelevanceId() {
        return relevanceId;
    }

    public void setRelevanceId(Relevance relevanceId) {
        this.relevanceId = relevanceId;
    }

    public ObservableBehavior getObservableBehaviorId() {
        return observableBehaviorId;
    }

    public void setObservableBehaviorId(ObservableBehavior observableBehaviorId) {
        this.observableBehaviorId = observableBehaviorId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BehavioralSkill)) {
            return false;
        }
        BehavioralSkill other = (BehavioralSkill) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jobs.jpa.BehavioralSkill[ id=" + id + " ]";
    }
    
}
